#ifndef LYRICSEARCHWIDGET_H
#define LYRICSEARCHWIDGET_H

#include<QtGui>
#include<QtNetwork>
#include<QtXml>
namespace Ui {
class LyricSearchWidget;
}

class LyricSearchWidget : public QWidget
{
    Q_OBJECT
    
public:
    explicit LyricSearchWidget(const QString &trackName, QWidget *parent = 0);
    QNetworkReply* searchLyric(const QString &title,const QString &artist);
    QNetworkReply* downloadLyric(const QString &id,const QString &title,const QString &artist);
    void parseXml(const QByteArray &array);
    qint32 getCode(int,const char *);
    char *hexString(const QString&);
    ~LyricSearchWidget();
private:
    Ui::LyricSearchWidget *ui;
    QString ar;
    QString ti;
    QString trackName;
    QStringList ids;
    QStringList artists;
    QStringList titles;
    QMap<QString,int> treeItemIno;
    QNetworkAccessManager* netManager;
    QNetworkRequest* request;
    QNetworkReply* searchReply;
    QNetworkReply* downReply;
    QTextCodec* textCodec;

    int idx;
    static QString ttserver;
private slots:
    void onArTextChanged(QString);
    void onTiTextChanged(QString);
    void onItemClicked(QTreeWidgetItem * item, int column);
    void onItemDblClicked(QTreeWidgetItem * item, int column );
    void onSearchFinished();
    void onDownloadFinished();
    void onDownClicked();
    void onSearchClicked();
signals:
    void searchResult(bool);
    void downFinished(QString);
};

#endif // LYRICSEARCHWIDGET_H
